
<?php
/**
 * Created by PhpStorm.
 * User: hg116
 * Date: 2018/11/29
 * Time: 19:17
 */

include "config.php";

if($_SERVER["REQUEST_METHOD"]=="POST"){
if(isset($_REQUEST["uname"])&&isset($_REQUEST["upwd"])){
$uname=$_REQUEST["uname"];
$upwd=$_REQUEST["upwd"];

//4.准备sql语句

$sql="INSERT INTO uphone (`u_pname`,`u_pwd`) VALUE ('".$uname."','".$upwd."');";

//print_r($sql);
//5.执行sql语句 有返回值
$result=$conn->query($sql);
//    print_r($result);
//
if($result==1){
print_r(json_encode(array("msg"=>"注册成功","status"=>1)));
}else{
print_r(json_encode(array("msg"=>"注册失败","status"=>0)));
}
//关闭数据库
$conn->close();
}else{
print_r(json_encode(array("msg"=>"密码或用户名不能为空","status"=>-1)));
}

}else{
print_r(json_encode(array("msg"=>"不支持get请求","status"=>-2)));
}